package initialize

import (
	"gitee.com/DonHz/electronic-business-systems/mxshop-api/order_web/middlewares"
	"gitee.com/DonHz/electronic-business-systems/mxshop-api/order_web/router"
	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
	"net/http"
)

func Routers() *gin.Engine {
	r := gin.Default()
	r.GET("/health", func(c *gin.Context) {
		c.JSON(http.StatusOK, gin.H{
			"code":    http.StatusOK,
			"success": true,
		})
	})
	// 配置跨域
	r.Use(middlewares.Cors())
	ApiGroup := r.Group("/o/v1")
	router.InitOrderRouter(ApiGroup)
	router.InitShopCartRouter(ApiGroup)
	zap.S().Debug("初始化 router 完成")
	return r
}
